package main

type VehicleAxel struct {
	A int
}

var VehicleTirePostions = [...][4][4]int{
	{
		{0, 2, 1, 0},
		{0, 4, 3, 0},
		{0, 0, 0, 0},
		{0, 0, 0, 0},
	},
	{
		{0, 2, 1, 0},
		{0, 6, 3, 0},
		{10, 9, 8, 7},
		{14, 13, 12, 11},
	},
	{
		{0, 2, 1, 0},
		{6, 5, 4, 3},
		{10, 9, 8, 7},
		{14, 13, 12, 11},
	},
	{
		{0, 2, 1, 0},
		{10, 9, 8, 7},
		{0, 0, 0, 0},
		{0, 0, 0, 0},
	},
	{
		{0, 2, 1, 0},
		{0, 10, 7, 0},
		{0, 0, 0, 0},
		{0, 0, 0, 0},
	},
	{
		{0, 2, 1, 0},
		{10, 9, 8, 7},
		{0, 14, 11, 0},
		{0, 0, 0, 0},
	},
	{
		{0, 2, 1, 0},
		{10, 9, 8, 7},
		{14, 13, 12, 11},
		{0, 0, 0, 0},
	},
	{
		{0, 1, 2, 0},
		{3, 4, 5, 6},
		{0, 0, 0, 0},
		{0, 0, 0, 0},
	},
	{
		{0, 1, 2, 0},
		{3, 4, 5, 6},
		{7, 8, 9, 10},
		{0, 0, 0, 0},
	},
	{ // 301	ZT头1
		{0, 2, 1, 0},
		{6, 5, 4, 3},
		{0, 0, 0, 0},
		{0, 0, 0, 0},
	},
	{
		{0, 2, 1, 0},
		{6, 5, 4, 3},
		{10, 9, 8, 7},
		{0, 0, 0, 0},
	},
}

func (p *VehicleAxel) Axel(vehicleType, cardid, sn int) int {
	if vehicleType == 3 || vehicleType == 303 || vehicleType == 304 || vehicleType == 305 || cardid > 0 {
		return 4
	}

	index := p.typeIndex(vehicleType)
	if index >= 0 {
		vtp := VehicleTirePostions[index]
		for y := 0; y < 4; y++ {
			for x := 0; x < 4; x++ {
				if sn == vtp[y][x] {
					return y
				}
			}
		}
	}
	return -1
}

func (p *VehicleAxel) typeIndex(vehicleType int) int {
	switch vehicleType {
	case 1:
		return 0
	case 2, 4, 5:
		return 1
	case 6:
		return 2
	case 101:
		return 3
	case 102:
		return 4
	case 103:
		return 5
	case 104, 105:
		return 6
	case 201:
		return 7
	case 202:
		return 8
	case 301:
		return 9
	case 302:
		return 10
	}

	return -1
}
